//#include<stdio.h>
//void month_day(int year,int yearday,int *pmonth,int *pday)
//{
//
//	int k,a;
//	int b[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};                                       
//	a=(year%4==0&&year%100!=0)||year%400==0;  
//	for(k=1;yearday>b[a][k];k++)
//		yearday-=b[a][k];
//		*pmonth=k;
//		*pday=yearday;
//	
//} 
//int main()
//{
//	int day,month,year,yearday;
//	printf("input year and yearday");
//	scanf("%d %d",&year,&yearday);
//	month_day(year,yearday,&month,&day);
//	printf("%d-%d-%d",year,month,day);
//	return 0;	 
//
//
//
//
//}
//#include<stdio.h>
//int main()
//{
//	int a[6]={1,2,3,4,5,6};
//	int sum = 0;
//	int *p=a;
//	for(p = a;p<a+6;p++)
//	{
//		if(*p%2==0)
//		{
//			sum = sum+*p;
//		}
//	}
//	printf("%d",sum);	
//		
//}
//#include<stdio.h>
//int main()
//{
//	char a[]={'a','b','c','d','e'};
//	int sum = 0;
//	char *p=a;
//	for(p=a;p<a+5;p++)
//	{
//		printf("%c\n",*p+2);
//
//	}
//	return 0;
//}
//#include<stdio.h>
//void month_day(int year,int yearday,int *pmonth,int *pday)
//{
//
//	int k,a;
//	int b[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};                                       
//	a=(year%4==0&&year%100!=0)||year%400==0;  
//	for(k=1;yearday>b[a][k];k++)
//		yearday-=b[a][k];
//		*pmonth=k;
//		*pday=yearday;
//	
//} 
//int main()
//{
//	int day,month,year,yearday;
//	printf("input year and yearday");
//	scanf("%d %d",&year,&yearday);
//	month_day(year,yearday,&month,&day);
//	printf("%d-%d-%d",year,month,day);
//	return 0;	 
//}
#include<stdio.h>
int haha(int a)
{
	if((a%400==0)||(a%100!=0&&a%4==0))
    {
        return 1;
    }
    else
    {
        return 2;
    }	
}
void test(int a,int b)
{
	int arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int brr[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	if(haha(a)==1)
	{
		printf("%d\n",arr[b]);
	}
	else
	{
		printf("%d\n",brr[b]);
	}
}
int main()
{
	int year,month;
	scanf("%d %d",&year,&month);
	test(year,month);
	return 0;	
} 
